const app = getApp()
import {imageUrl} from "../../utils/imageutil.js"
Page({
  data: {
    imageUrl,
    order:'',
    refund_bak:"",
    typeList:[{
      title:'退货退款',
      type:'1'
    },{
      title:'换货',
      type:'2'
    },{
      title:'其他问题',
      type:'3'
    }],
    typeIndex:-1,
    stateList:[{
      title:'未收到货',
      type:'1'
    },{
      title:'已收到货',
      type:'2'
    }],
    stateIndex:-1,
    whyList:[{
      title:'多拍、错拍、不想要',
      type:'1'
    },{
      title:'重量/数量/大小等描述不符',
      type:'2'
    },{
      title:'少件/漏发',
      type:'3'
    },{
      title:'商品变质/保质期与商品描述不符',
      type:'4'
    },{
      title:'质量问题',
      type:'5'
    }],
    whyIndex:-1,
  },
  onLoad: function (options) {
    this.setData({
      order:options.order
    })
  },
  typeChange(e){
    this.setData({
      typeIndex:e.detail.value
    })
  },
  stateChange(e){
    this.setData({
      stateIndex:e.detail.value
    })
  },
  whyChange(e){
    this.setData({
      whyIndex:e.detail.value
    })
  },
  change_refund_bak(e){
    this.setData({
      refund_bak:e.detail.value
    })
  },
  bottomTap(){
    let type = Number(this.data.typeIndex) + 1
    if(this.data.typeIndex==-1){
      getApp().showToast('请先选择申请类型')
      return
    }
    if(type==3&&this.data.refund_bak==''){
      getApp().showToast('请先输入您的问题')
      return
    }
    getApp().globalData.posts('/api/ouyoung/order/applyRefundJfOrder', {
      order_number: this.data.order,
      type,
      refund_bak:this.data.refund_bak
    }).then(res => {
      getApp().showModal(res.data.msg).then(() => {
        wx.navigateBack()
      })
    })
  },
})